package 基础语法;

import java.util.ArrayList;
import java.util.Arrays;

public class 增强for遍历 {
    public static void main(String[] args) {
        int[] p = new int[] { 1, 2, 3, 3 };
        ArrayList<Integer> a = new ArrayList<>();
        a.add(1);
        a.add(2);
        a.add(3);
        for (int pi : p) {
            pi = 2;// 不改变原数据
            System.out.println(pi);
        }
        System.out.println(Arrays.toString(p));
        for (Integer ai : a) {
            System.out.println(ai);
        }

    }

}
